<template>
    <div class="admin-content">

        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">新增品牌</strong> /
                <small>Create A New Brand</small>
            </div>
        </div>


        <form class="am-form" action="" method="post">

            <div class="am-g am-margin-top">
                <div class="am-u-sm-4 am-u-md-2 am-text-right">
                    商品品牌
                </div>
                <div class="am-u-sm-8 am-u-md-4">
                    <input type="text" class="am-input-sm" v-model="category.name">
                </div>
                <div class="am-hide-sm-only am-u-md-6">*必填，不可重复</div>
            </div>



            <div class="am-g am-margin-top">
                <div class="am-u-sm-4 am-u-md-2 am-text-right">
                    缩略图
                </div>

                <div class="am-u-sm-8 am-u-md-6 am-u-end col-end">
                    <div class="am-form-group am-form-file new_thumb">
                        <button type="button" class="am-btn am-btn-secondary am-btn-sm">
                            <i class="am-icon-cloud-upload" id="loading"></i> 上传新的缩略图
                        </button>
                        <input type="file" id="thumb_upload">
                    </div>


                    <hr data-am-widget="divider" style="" class="am-divider am-divider-dashed"/>

                    <div>
                        <!--<img src="" id="img_show" style="max-height: 200px;max-width:400px;">-->
                    </div>
                </div>
            </div>


            <div class="am-g am-margin-top">
                <div class="am-u-sm-4 am-u-md-2 am-text-right">
                    品牌描述
                </div>
                <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                    <textarea rows="4" v-model="category.desc"></textarea>
                </div>
            </div>


            <div class="am-g am-margin-top">
                <div class="am-u-sm-4 am-u-md-2 am-text-right">
                    是否显示
                </div>
                <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                    <label class="am-radio-inline">
                        <input type="radio" value="1" v-model="category.is_show" checked> 是
                    </label>
                    <label class="am-radio-inline">
                        <input type="radio" value="0" v-model="category.is_show"> 否
                    </label>
                </div>
            </div>

            <div class="am-g am-margin-top">
                <div class="am-u-sm-4 am-u-md-2 am-text-right">
                    排序
                </div>
                <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                    <input type="text" v-model="category.sort_order" class="am-input-sm" value="99">
                </div>
            </div>

            <div class="am-margin">
                <button @click.prevent="onSubmit" class="am-btn am-btn-primary am-radius">提交保存</button>
            </div>
        </form>


    </div>
</template>

<script>
    export default {
        ready() {

        },
        data: function () {
            return {
                category: {}
            }
        },
        methods: {
            onSubmit: function () {
                this.$http.post('/lxSystem/ad_category', this.category).then((response) => {
                    this.$router.go({name: 'category'})

                });
            }
        }
    }
</script>
